package com.jiker.keju;

public class Calculation {

    public String calc(String data) {
        int [] param = getKmWait(data);
        return "收费" + Math.round(calcKm(param[0]) + 0.25 * param[1]) +"元";
    }

    private double calcKm(int km) {
        if (km <= 2) {
            return new CalcStart().calcSeed(km);
        } else if(km > 8){
            return new CalcLong().calcSeed(km);
        } else {
            return new CalcMedium().calcSeed(km);
        }
    }


    private int [] getKmWait(String data) {
        data = data.replace("公里,等待",",").replace("分钟", "");
        String [] aData = data.split(",");
        int [] result = new int[2];
        result[0] = Integer.parseInt(aData[0]);
        result[1] = Integer.parseInt(aData[1]);
        return result;
    }

}
